import { useRefModel } from '@/utils/hooks'

export default defineComponent({
  name: 'SRadioGroup',
  props: {
    modelValue: {
      type: [String, Object],
      required: true,
    },
    options: {
      type: [Array, Object],
      default: () => [],
    },
    disabled: {
      type: [Boolean, Object],
      default: false,
    },
    onChange: {
      type: [Function, Object],
      default: () => () => {},
    },
  },
  emits: ['update:modelValue'],
  setup(props, { slots, expose, emit, attrs }) {
    const tmp_props = reactive<any>({})
    Object.keys(props).forEach((key: any) => {
      tmp_props[key] = props[key]?.value ?? props[key]
    })
    const keyword = useRefModel(props, 'modelValue', emit)
    const $props = {
      ...lodash.omit(tmp_props, ['modelValue']),
      ...attrs,
    }
    return () => <a-radio-group vModel:value={keyword.value} {...$props} />
  },
})
